import * as cheerio from 'cheerio';
import data from './data.json' assert { type: 'json' }
import fs from 'fs'

let result = [];


let pre = 'https://www.aliyundrive.com/s/';
data.forEach(({ data, tr, tag }) => {
  let obj = {};
  if (data.split('\t').length < 2) return;
  let [name, url] = data.split('\t');
  name = name.replace(/👎/, '');
  name = name.replace(/👍/, '');
  name = name.replace(/^\([0-9]\)/, '');
  obj.name = name;
  obj.url = pre + url;
  tr = tr.replaceAll('td', 'h1');
  const $ = cheerio.load(tr);
  obj.description = $('[tooltip]').attr().tooltip;
  obj.tags = tag;
  result.push(obj)
})



console.log(result);

fs.writeFileSync('../server/data_ready.json', JSON.stringify(result));

console.log(data.length);